A wireless local area network (WLAN) based on the Institute of Electrical and Electronics Engineers (IEEE) 802.11 is a local area network in which a radio frequency technology is adopted and a wireless channel is used as a transmission medium. A station (STA), an access point (AP), and the like are usually included in a WLAN. A STA refers to a device having a WLAN interface. In addition to functions of a STA, an AP may further be connected to a distribution system through an interface provided to an associated STA by a wireless medium, and is responsible for implementing communication between STAs or between a STA and a wired network. Multiple STAs may be associated with a same AP.
Before accessing a WLAN, a STA first needs to search for a network in a region in which the STA is located, discovers an available AP, and is associated with the discovered available AP. An available AP is usually discovered in two manners: active scanning and passive scanning.
Active scanning manner: A STA broadcasts a probe request frame on all channels and actively scans for an available AP on a channel, and receives a probe response frame returned by an available AP, to obtain information about the available AP.
Passive scanning manner: An AP periodically sends a beacon frame, and a STA performs listening channel by channel to capture a beacon frame sent by an AP, to obtain information about an available AP.
All STAs associated with a same AP and the AP together form one basic service set (BSS). A BSS may be identified by a basic service set identifier (BSSID). A BSSID is usually a media access control (MAC) address of an AP.
A wireless fidelity (Wi-Fi) technology is a short-range wireless communication technology. Based on advantages such as convenient use and a high transmission rate, the wireless fidelity technology is widely applied in aspects of both construction of a WLAN and access to a wide area network. In recent years, with ongoing popularization and rapid growth of various terminal devices, such as a notebook computer and a mobile phone, which support the Wi-Fi technology, a WLAN technology has become an important technology for industrial informatization, home informatization, and individual informatization, is widely applied to various sites such as enterprises, homes, campuses, and hospitals, and brings about various WLAN-related service requirements and user experience requirements. Current research focuses of the WLAN technology are as follows: For example, in a high-density service scenario with complex service classification and centralized deployment, one focus is how a user discovers a service that can be provided by a network and rapidly and effectively accesses a corresponding network according to a service, for example, printing, which the user requires. Further, another focus is how to discover a device capability such as support of Wi-Fi Direct and Bluetooth when the user discovers a required service and intends to perform direct interaction through Wi-Fi with a device providing the service.
Currently, device discovery and establishment of a point-to-point (P2P) direct association may be performed using a Wi-Fi Direct technology, and content and the like may be shared, presented, printed, and synchronized between devices. The core of the Wi-Fi Direct technology is that, required devices are discovered among devices in a P2P manner, so that devices construct or join a group and connections are established among the devices, and subsequently communication is performed inside the group. The Wi-Fi Direct technology provides near-field device discovery, in which only device-based discovery and search can be provided, and a device needs to periodically listen on a channel to respond to device discovery and information sharing. Therefore, limited by a distance between devices, the Wi-Fi Direct technology cannot provide service-based discovery and search, and a device needs to consume a lot of resources to listen on a channel.